<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: yajuan.wang
  Date: 2018/12/12
  Time: 15:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:include page="/pages/sysIndex/default.jsp"/>
<head>
</head>
<style>
    a {
        text-decoration: none;
        color: #0C0C0C;
        font-size: 12px;
    }

    .box-body {
        margin: 10px 10px;
    }

</style>
<div class="main-content">
    <div class="box box-main">
        <div class="box-header">
            <%--<div class="box-title">--%>
            <%--<i class="fa icon-trophy"></i> 审批节点--%>
            <%--</div>--%>

        </div>
        <div class="box-body">

            <form id="detailForm" action="<c:url value="/web/admin/plannerInspection/getPositionByArea.action"/>" method="post"
                  class="form-inline hide" data-page-no="1" data-page-size="20" data-order-by="">
                <input type="hidden" name="plannerId" id="plannerId" value="${plannerId}"/>
            </form>

            <table id="assignPositionGrid"></table>
            <div id="assignPositionGridPage"></div>
            <div class="box-footer">
                <div class="row">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-sm btn-primary" onclick="saveUser()"><i class="fa fa-check"></i>
                            保 存
                        </button>&nbsp;

                        <button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="closeView()"><i
                                class="fa fa-times"></i> 关 闭
                        </button>
                    </div>
                </div>
            </div>

        </div>

    </div>
</div>

<script>
    $('#assignPositionGrid').dataGrid({
        searchForm: $("#detailForm"),
        showCheckbox: true,
        columnModel: [
            {header: '关键字', name: 'id', index: 'id', width: 50, align: "center"},
            {header: '岗位名称', name: 'name', index: 'name', width: 200, align: "center"},
            {header: '岗位编号', name: 'code', index: 'code', width: 100, align: "center"},

        ],
        // 加载成功后执行事件
        ajaxSuccess: function (data) {

        }
    });


    function closeView() {
        console.log("关闭");
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }

   function saveUser(){
        var ids = $("#assignPositionGrid").jqGrid("getGridParam", "selarrrow");
       $.ajax({
            type: 'post',
            url: "<c:url value="/web/admin/plannerInspection/saveAssignPosition.action" />",
            data: {"assignIds": JSON.stringify(ids), "plannerId": $("#plannerId").val()},
            dataType: 'json',
            async: false,
            success: function (data) {
                js.showMessage(data.msg);
                closeView();
                parent.$("#dataGrid").dataGrid("refresh");


            },
            error: function () {
                js.showMessage("出错了，请联系管理员");
            }
        });
    }

</script>

